package net.test;

import java.awt.Color;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;

import javax.imageio.ImageIO;

import ths.web.i18n.I18nManager;
import ths.web.i18n.Language;

import ths.core.security.Base32;

import net.shop.common.LanguageKeyConstants;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class Main {

	public static void main(String[] args) {
		//ApplicationContext applicationContext = new ClassPathXmlApplicationContext("test-applicationContext.xml");
		//I18nManager i18n = (I18nManager) applicationContext.getBean("i18nManagerFactory");
		//Language language = i18n.getLanguage("en");
		
		//mvnforum.user.addmembersuccess.login_this_email
		//mvnforum.user.addmember.correct_email_remind
		//String msg = language.getMessage(LanguageKeyConstants.MVNFORUM_USER_ADDMEMBER_CORRECT_EMAIL_REMIND);
		//System.out.println(msg);

		
		//String asii = Base62.bytesToString("tianhaishen".getBytes(), true);
		//System.out.println(asii);
		
		/*
		String encode = Base32.encode("田海深".getBytes());
		String decode = new String(Base32.decode(encode));
		
		System.out.println(encode);
		System.out.println(decode);
		*/
		
		/*
		try {
			BufferedImage originalImage = ImageIO.read(new File("c:\\p2.jpg"));
			File destFile = new File("c:\\p2-50x50.jpg");
			
			ImageUtil.zoom(originalImage, destFile, 50, 50);
		} catch (IOException e) {
			e.printStackTrace();
		}
		*/
		/*
		try {
			
			BufferedImage originalImage = ImageIO.read(new File("c:\\p2.jpg"));
			
			
			ths.core.graphic.ImageThumbnail thumbnail = new ths.core.graphic.ImageThumbnail();
			thumbnail.from(originalImage).resize(100, 100).saveAs(new File("c:\\p2-100x100-new.jpg"));
			thumbnail.from(originalImage).resize(300, 300).saveAs(new File("c:\\p2-300x300-new.jpg"));
			thumbnail.from(originalImage).scale(0.3F).saveAs(new File("c:\\p2-scale-0.3.jpg"));
			
			thumbnail.from(originalImage).background(Color.WHITE).resize(300, 300).saveAs(new File("c:\\p2-300x300-bg.jpg"));
			thumbnail.from(originalImage).background(Color.WHITE).resize(100, 100).saveAs(new File("c:\\p2-100x100-bg.jpg"));
		
			
			BufferedImage img = ImageIO.read(new File("c:\\watermark.png"));
			ths.core.graphic.ImageWatermark watermark = new ths.core.graphic.ImageWatermark();
			
			watermark.from(originalImage).position(ths.core.graphic.Position.bottomRight, 20)
				.icon(img).saveAs(new File("c:\\p2-watermark-icon.jpg"));
			
			watermark.from(originalImage).position(ths.core.graphic.Position.bottomRight, 0)
				.text("http://www.99buy.com.cn").saveAs(new File("c:\\p2-watermark-text.jpg"));
			
		} catch (IOException e) {
			e.printStackTrace();
		}
		*/
		/*
		try {
			BufferedImage originalImage = ImageIO.read(new File("c:\\p2.jpg"));
			//BufferedImage watermarkImage = ImageIO.read(new File("watermark.png"));

			Thumbnails.of(originalImage).size(200, 200).outputQuality(1.0f).toFile("c:\\p2-200x200.jpg");
			Thumbnails.of(originalImage).size(50, 50).outputQuality(1.0f).toFile("c:\\p2-50x50.jpg");
			//Thumbnails.of(originalImage).watermark(Positions.BOTTOM_RIGHT, watermarkImage, 0.5f);

		} catch (IOException e) {
			e.printStackTrace();
		}*/
		
		//System.out.println(java.util.UUID.randomUUID().toString());
		String uri = "/admin/product-virtual-category.do";
		System.out.println(getActionName(uri));
		
	}
	
	private static String getActionName(String uri) {
		int begin = uri.lastIndexOf('/') + 1;
		return uri.substring(begin);
	}
}
